﻿using System;
using UnityEngine;

namespace EditorExtensions
{
    public class GUILayoutAPI
    {
          #region Basic

        private string mTextValue;
        private string mTextArea;
        private string mPassWordValue = String.Empty;
        private Vector2 mScrollPosition;

        private float mSliderValue;

        private int mToolbarIndex;
        private bool mToggleValue;

        private int mSelectedIndex;

        public void Draw()
        {
            GUILayout.Label("Label Hello IMGUI");
            GUILayout.BeginScrollView(mScrollPosition);
            {
                GUILayout.BeginVertical("box");
                {
                    GUILayout.BeginHorizontal();
                    //语法块特性
                    {
                        GUILayout.Label("TextField");
                        mTextValue = GUILayout.TextField(mTextValue);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Space(100);
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("TextArea");
                        mTextArea = GUILayout.TextArea(mTextArea);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("PasswordField");
                        mPassWordValue = GUILayout.PasswordField(mPassWordValue, '*');
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Button");
                        // GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Button", GUILayout.MinWidth(100), GUILayout.MinHeight(100), GUILayout.MaxWidth(150), GUILayout.MaxHeight(150)))
                        {
                            Debug.Log("Button Clicked");
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("RepeatButton");
                        if (GUILayout.RepeatButton("RepeatButton", GUILayout.Width(150), GUILayout.Height(150)))
                        {
                            Debug.Log("RepeatButton Clicked");
                        }
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Box");
                        GUILayout.Box("AutoLayout Box");
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("HorizontalSlider");
                        mSliderValue = GUILayout.HorizontalSlider(mSliderValue, 0, 1);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("VerticalSlider");
                        mSliderValue = GUILayout.VerticalSlider(mSliderValue, 0, 1);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginArea(new Rect(0, 0, 100, 100));
                    {
                        GUI.Label(new Rect(0, 0, 20, 20), "1");
                    }
                    GUILayout.EndArea();

                    GUILayout.Window(1, new Rect(0, 0, 100, 100), (id) =>
                    {
                    }, "2");

                    mToolbarIndex = GUILayout.Toolbar(mToolbarIndex, new[]
                    {
                        "1", "2", "3", "4", "5"
                    });

                    mToggleValue = GUILayout.Toggle(mToggleValue, "Toggle");
                    mSelectedIndex = GUILayout.SelectionGrid(mSelectedIndex, new[]
                    {
                        "1", "2", "3", "4", "5"
                    }, 2);
                }

                GUILayout.EndVertical();
            }
            GUILayout.EndScrollView();
        }

        #endregion
    }
}